﻿using System;
using System.Text.RegularExpressions;
using System.Windows.Automation;
using MS.Internal.Mita.Foundation;

public static class UIConditionHelper
{
    private static Regex _regex;

    static UIConditionHelper()
    {
        if (_regex == null)
        {
            _regex = new Regex("(?<name>([A-Za-z]+))[ ]*(?<cmpOp>=|(!=)){1}[ ]*(?<value>([']{1}[^']*[']{1})|[0-9]+|true)($|([ ]*(?<join>[&||]{2})[ ]*))");
        }
    }

    public static UICondition GetFromQueryString(string queryString)
    {
        if (!_regex.IsMatch(queryString))
        {
            throw new Exception("Invalid query string: " + queryString);
        }

        Match match = _regex.Match(queryString);

        while (match.Success)
        {

            string name = match.Result("${name}");
            string cmpOp = match.Result("${cmpOp}");
            string value = match.Result("${value}");
            string join = match.Result("${join}");
            bool isAndJoin = (join == "||") ? false : true;

            //UICondition c = UICondition.Create(
         
        }

        return null;
    }
}